﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Net;
using System.ComponentModel.DataAnnotations;
using SocialGame.Business;
using Social.Game.DAL;

namespace SocialGame.Models
{
    /// <summary>
    /// 
    /// </summary>
    public class QuestionModel
    {
        public int ID
        {
            get;
            set;
        }
        [Display(Name = "Tiêu đề")]
        [Required]
        public string QuestTitle
        {
            get;
            set;
        }
        [Required]
        [Display(Name = "Loại câu hỏi")]
        public QuestionTypeModel QuestType
        {
            get;
            set;
        }

        [Display(Name = "Nội dung")]
        public string QuestContent
        {
            get;
            set;
        }
        [Display(Name = "Cấp độ")]
        public int QuestLevel
        {
            get;
            set;
        }

        public FieldsModel Field
        {
            get;
            set;
        }
        [Required]
        [Display(Name = "Chủ đề")]
        public int FieldId
        {
            get;
            set;
        }
        [Display(Name = "Số câu trả lời")]
        public int AnswersCount
        {
            get;
            set;
        }
        [Display(Name = "Trạng thái")]
        public bool State
        {
            get;
            set;
        }
        [Display(Name = "Ảnh 1")]
        public string Image1
        {
            get;
            set;
        }
        [Display(Name = "Ảnh 2")]
        public string Image2
        {
            get;
            set;
        }
        [Display(Name = "Ảnh 3")]
        public string Image3
        {
            get;
            set;
        }
        [Display(Name = "Ảnh 4")]
        public string Image4
        {
            get;
            set;
        }
        public IEnumerable<QuestionTypeModel> ListQuestionType
        {
            get
            {
                var listQuestTypes = DbUtil.Database.Query<QuestionType>("SELECT * FROM QuestionType").ToArray();
                List<QuestionTypeModel> lists = new List<QuestionTypeModel>();
                foreach (var q in listQuestTypes)
                {
                    QuestionTypeModel qm = new QuestionTypeModel();
                    qm.QuestionName = q.QuestionName;
                    qm.QuestionType = q._QuestionType;
                    lists.Add(qm);
                }
                return lists;
            }
        }

        public IEnumerable<Social.Game.DAL.Field> ListField
        {
            get
            {
                return DbUtil.Database.Query<Social.Game.DAL.Field>("SELECT * FROM Fields").ToList();
            }
        }
        
    }
}